<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../../config.inc.php");
$_LangPath = "systemparam";	//語言檔參數，務必放在最前面

include_once(__Admin_Path."/logincheck.php");
include_once(__Language_Path."/selectlanguage_admin.php");
include_once(__Modules_Path."/LogRecord.lib.php");
include_once(__Modules_Path."/Tool.lib.php");
include_once(__Common_Path."/SysParam.inc.php");

$arrPower = CheckUsePower("SystemParam");
if($arrPower === false)ErrMsgOutputHTML("Error", "", 1);

if($_data["SpecialNumberABOddsGap"]*1 > 6){
	$GLOBALS["errormessage"] = "特碼A 和 特碼B 初始賠率的差距1 不能大於 6";
	ErrMsgOutputHTML("Error", "", 1);
}
if($_data["SpecialNumberABOddsGap2"]*1 > $_data["SpecialNumberABOddsGap"]*1){
	$GLOBALS["errormessage"] = "特碼A 和 特碼B 初始賠率的差距2 不能大於 ".$_data["SpecialNumberABOddsGap"];
	ErrMsgOutputHTML("Error", "", 1);
}
if($_data["SpecialNumberABOddsGap3"]*1 > $_data["SpecialNumberABOddsGap2"]*1){
	$GLOBALS["errormessage"] = "特碼A 和 特碼B 初始賠率的差距3 不能大於 ".$_data["SpecialNumberABOddsGap2"];
	ErrMsgOutputHTML("Error", "", 1);
}

$intChanged = 0;
reset($_KSysParam);
$arrLog = array();
while (list($k,$v)=each($_data)) {
	if ($_KSysParam[$k] != $v) {
		$strSQL = "update `bet_SystemParam` set ParamValue='".$v."' where ParamName='".$k."'";
		$arrLog[] = $k." = ".$v.", ";
		if(!PMA_mysql_query($strSQL, $_ConnMaster)){
			$GLOBALS["errormessage"] = "Update System Data Error!!";
			$GLOBALS["errorhidden"] = "\nErr: ".PMA_mysql_error($_ConnMaster).",\nSQL: ".$strSQL.",\nLine: ".__LINE__.",\nPage: ".__FILE__;
			ErrMsgOutputHTML("Error", "", 1);
		}
		$intChanged++;
	}
}
if ($intChanged > 0) {
	if(!makeSystemParamFile()){
		ErrMsgOutputHTML("Error", "", 1);
	}
}
AddData_Log($_SESSION["Admin_Info"] -> ID, "修改 System Param 資料", join("\n", $arrLog));
$GLOBALS["errormessage"] = "Update System Param Success!!";
ErrMsgOutputHTML("Error", "", 1);
?>
